package com.yaorange.jxc.supplier.controller;


import com.yaorange.jxc.supplier.entity.Supplier;
import com.yaorange.jxc.supplier.entity.SupplierPageRequestResult;
import com.yaorange.jxc.supplier.service.SupplierService;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @company: yaorange
 * @author: wu YanZu
 * @version: 1.0
 * @create: 2022-04-26 17:54:32
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    @PostMapping("/list")
    public Map<String,Object> findSupplisrList(@RequestBody SupplierPageRequestResult requestResult){
        Map<String, Object> supplisrMap = supplierService.findSupplisrList(requestResult);
        return supplisrMap;
    }

    @PostMapping("/save")
    public Result<?> saveSupplierById(@RequestParam Integer supplierId, Supplier supplier){

        Result result = supplierService.saveById(supplierId,supplier);

        return result;
    }

    @PostMapping("/delete")
    public Result<?> deleteSupplierById(@RequestParam List<Integer> ids){

        Integer rows = supplierService.deleteById(ids);
        if(rows == ids.size()){
            return Result.OK("请求成功",rows);
        }
        return Result.error("请求失败");
    }



















}
